package com.hb.core.pojo.project.notice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hb.core.pojo.project.notice.entity.NoticeBidSection;
import com.hb.core.pojo.project.section.dto.BidSectionDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 标段公告中间表 Mapper 接口
 * </p>
 *
 * @author zhongdl
 * @since 2021-09-10
 */
public interface NoticeBidSectionMapper extends BaseMapper<NoticeBidSection> {

    /**
     * 获取指定标段并且指定公告发布状态的数量
     *
     * @param sectionId
     * @param deployedStatus
     * @return
     */
    @Select("select count(*) from trade_notice n where n.deploy_status=#{deployedStatus} and n.id " +
            "in (select nbs.notice_id from trade_notice_bid_section nbs where nbs.section_id=#{sectionId})")
    int findDeployedNoticeBySectionId(@Param("sectionId") Long sectionId, @Param("deployedStatus") int deployedStatus);

    /**
     * 查询指定的标段是否已经发布过首次公告
     *
     * @param sectionIds
     * @return 公告数量
     */
    int existsFirstNotice(List<Long> sectionIds);
    /**
     *
     * @Description: 查询公告的标段列表
     * @Author: zhongdl
     * @Date:2022/3/4 10:45
     * @param noticeId:
     * @return: {@link List< BidSectionDTO> }
     **/
    List<BidSectionDTO> listNoticeBidSection(@Param("noticeId") Long noticeId);
}
